#define _CRT_SECURE_NO_WARNINGS
#include"SeqList.h"
void SLInt(SL* p)
{
	p->a = (SLDataType*)malloc(sizeof(SLDataType) * IntCapacity);
	if (p->a == NULL)
	{
		perror("malloc fail");
		return;
	}
	p->size = 0;
	p->capacity = IntCapacity;
}
void SLDestroy(SL* p)
{
	free(p->a);
	p->a = NULL;
	p->capacity = p->size = 0;
}
void SLPrint(SL* p)
{
	int i = 0;
	for (i = 0;i < p->size;i++)
	{
		printf("%d ", (p->a)[i]);
	}
	printf("\n");
}
void SLExpand(SL* p)
{
	if (p->size == p->capacity)
	{
		SL* tmp = realloc(p->a, sizeof(SLDataType) * (p->capacity) * 2);
		if (tmp == NULL)
		{
			perror("realloc fail");
			return;
		}
		p->a = tmp;
		p->capacity = p->capacity * 2;
	}
}
void SLPushBack(SL* p, SLDataType x)
{
	SLExpand(p);
	p->a[p->size++] = x;
}
void SLPopBack(SL* p)
{
	assert(p->a != NULL);
	assert(p->size > 0);
	p->size--;

}